//
//  UIViewController+VCExtra.h
//
//  Created by jzkj on 16/4/5.
//  Copyright © 2016年 Mac. All rights reserved.
//

#import <UIKit/UIKit.h>

///导航栏默认属性设置
#ifndef NavigationItemDefualtFrame
    #define NavigationItemDefualtFrame CGRectMake(0,0,30,30)
#endif

#ifndef NavigationTitleDefualtColor
    #define NavigationTitleDefualtColor [UIColor whiteColor]///[UIColor colorWithRed:26.0/255.0 green:196.0/255.0 blue:191.0/255.0 alpha:1.0]
#endif

#ifndef NavigationBarBgColor
    #define NavigationBarBgColor UIColorFormRGB_theme
#endif

#ifndef NavigationTitleDefualtFontSize
    #define NavigationTitleDefualtFontSize 16
#endif

@interface UIViewController (PushExtra)

- (void)navigationPushViewController:(Class)vcClass;
- (void)navigationPushViewController:(Class)vcClass animation:(BOOL)animation;
- (void)navigationPushViewController:(Class)vcClass withOperation:(void (^)(id vcInstance))operation;
- (void)navigationPushViewController:(Class)vcClass animation:(BOOL)animation withOperation:(void (^)(id vcInstance))operation;


/**
 *从vc导航到vcClass
 * @param vc 所在的UIViewController
 * @param vcClass 将要跳转的UIViewController
 * @return void
 * @see navigationViewController:pushViewController:withOperation:
 * @warning vc的navigationViewController应该非空并且vcClass应该是一种UIViewController
 **/
+ (void)navigationViewController:(UIViewController *)vc pushViewController:(Class)vcClass;

/**
 *从vc导航到vcClass
 * @param vc 所在的UIViewController
 * @param vcClass 将要跳转的UIViewController Class
 * @param animation 动画
* @param oparation 添加额外的操作,push之前
 * @return void
 * @see navigationViewController:pushViewController:
 * @warning vc的navigationViewController应该非空并且vcClass应该是一种UIViewController,operation可以为空
 **/
+ (void)navigationViewController:(UIViewController *)vc pushViewController:(Class)vcClass animation:(BOOL)animation withOperation:(void (^)(id vcInstance))operation;

@end


@interface UIViewController (PopExtral)

- (instancetype)popSelf;
- (NSArray *)popToRootViewController;
- (instancetype)poptoViewControllerWithIndex:(NSUInteger)index;

- (instancetype)popSelfWithAnimation:(BOOL)animation;
- (NSArray *)popSelfToRootViewControllerWithAnimation:(BOOL)animation;
- (instancetype)poptoViewControllerWithIndex:(NSUInteger)index animation:(BOOL)animation;
@end

@interface UIViewController (PresentExtral)
- (void)presentViewController:(Class)vcClass;
- (void)presentViewController:(Class)vcClass withOperation:(void (^)(id presentedVC))operation;
- (void)presentViewController:(Class)vcClass animation:(BOOL)animation;
- (void)presentViewController:(Class)vcClass animation:(BOOL)animation withOperation:(void(^)(id presentedVC))operation;
@end

@interface UIViewController (AppExtral)

+ (id<UIApplicationDelegate> )appDelegate;
+ (instancetype)appRootViewController;

///navigation
+ (UINavigationController *)appNavigationController;
+ (instancetype)appNavigationRootViewController;
+ (instancetype)appNavigationTopViewController;
+ (instancetype)appNavigationVisibleViewController;

///tabBarController
+ (UITabBarController *)appTabBarController;
+ (instancetype)appTabBarSelelctedViewController;
+ (instancetype)appTabBarTopViewController;
+ (instancetype)appTabBarVisibleViewController;
@end

@interface UIViewController (NavigationItemExtral)<UIGestureRecognizerDelegate>

- (void)customNavigationBar;
- (void)customNavigationBarWithBackgroundImage:(UIImage *)bgImage;

///设置通用的返回图片
- (void)setLeftCustomerItemImage:(UIImage *)image;
+ (void)setLeftCustomerItemImage:(UIImage *)image;
///自定义左item
- (void)setLeftCustomerItem;
- (UIButton *)setLeftCustomerItemTitle:(NSString *)title;
///使用通用的图片
- (UIButton *)setLeftCustomerItemWithTarget:(id)target selector:(SEL)selector;
- (UIButton *)setLeftCustomerItemTitle:(NSString *)title target:(id)target selector:(SEL)selector;
- (UIButton *)setLeftCustomerItemImage:(UIImage *)leftImage target:(id)target selector:(SEL)selector;

- (UIButton *)setRightItemImage:(UIImage *)rightImg target:(id)target selector:(SEL)selector;
- (UIButton *)setRightItemTitle:(NSString *)title target:(id)target selector:(SEL)selector;

///block support  -  block handler more easy to do actions
- (UIButton *)setLeftCustomerItemWithHandler:(void (^)(id sender))clickHandler;
- (UIButton *)setLeftCustomerItemTitle:(NSString *)title handler:(void (^)(id sender))clickHandler;
- (UIButton *)setLeftCustomerItemImage:(UIImage *)leftImage handler:(void (^)(id sender))clickHandler;

- (UIButton *)setRightItemImage:(UIImage *)rightImg handler:(void (^)(id sender))clickHandler;
- (UIButton *)setRightItemTitle:(NSString *)title handler:(void (^)(id sender))clickHandler;

@end

@interface UIViewController (NavigationBarExtral)
///setup navgation bar
+ (void)setupNavigationBar;
@end

@interface UIViewController (NavigationTitleActivityIndicatorCategroy)

- (void)hideTitleActivityIndicator;
@end
